import pandas as pd
import wx.grid


class GenericTable(wx.grid.GridTableBase):
    def __init__(self, data, rowLabels=None, colLabels=None):
        wx.grid.GridTableBase.__init__(self)
        self.data = data
        self.rowLabels = rowLabels
        self.colLabels = colLabels

    def IsEmpty(self, coords):
        return False

    def GetValue(self, row, col):
        return self.data[row][col]

    def SetValue(self, row, col, value):
        pass

    def GetRowLabelValue(self, row):
        return self.rowLabels[row]

    def GetColLabelValue(self, col):
        return self.colLabels[col]

    def GetNumberRows(self):
        return len(self.rowLabels)

    def GetNumberCols(self):
        return len(self.colLabels)


class SimpleGrid(wx.grid.Grid):
    def __init__(self, parent):
        wx.grid.Grid.__init__(self, parent, -1)
        exl = pd.read_excel("../../fake2excel.xlsx")
        rows = [str(x) for x in range(len(exl.values))]
        table = GenericTable(exl.values, rows, exl.columns)

        self.SetTable(table, True)


class MyFrame(wx.Frame):
    def __init__(self, parent):
        super().__init__(parent, -1, "A Grid", size=(275, 275))

        grp = SimpleGrid(self)


if __name__ == '__main__':
    app = wx.App()

    frame = MyFrame(None)
    frame.Show(True)

    app.MainLoop()
